<%@ page language="java" import="java.util.*,hibernate.VGlUserinfo,com.ctctc.business.manager.service.jydz.JydzService" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="commontaglib"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
 
<html>
  <head>
    <link rel="stylesheet" href="<%=path%>/css/liaotianshi.css" type="text/css" />
    <link rel="stylesheet" href="<%=path%>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=path%>/css/cupertino/jquery-ui.custom.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=path%>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=path%>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path%>/js/jquery-ui.custom.min.js"></script>  
    <script type="text/javascript" src="<%=path%>/js/i18n/grid.locale-cn.js"></script> 
    <script type="text/javascript" src="<%=path%>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<%=path%>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
    <script type="text/javascript" src="<%=path%>/js/common.js"></script>
    <style>
			html, body {
				margin: 0;			 
				padding: 0;	 
			    font-size: 85%;
			}
	</style>
	<style type="text/css">
	    #common_box{width:400px;position:fixed;_position:absolute;right:0;top:40%;border:1px solid #789;background:#fff;z-index:88}
	    #cli_on{width:30px;height:100%;float:left;cursor:pointer;background:#ac8932;text-align:center;line-height:180px}
	</style>
    
  </head>
  
  <script type="text/javascript">  
    var qieye = 0;
    $(function(){ 
    $("#chax").button();
    $("#reset").button();
    loadTab(0);
    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#tabs" ).tabs({
		    select: function(event, ui) {
		    var i =ui.index;	    
		    if(i==''){
		    i="0";
		    }
		    qieye = i;
		    loadTab(i);           
  		  }	
	});
 });
 
 function loadTab(i){ 
    $("#myTab"+i).jqGrid({      
    url:'<%=path%>/info/xsJqgrid.action?index='+i,  //index切页  0为发起1为接受2为达成
    datatype: 'json',
    mtype: 'post',         
   	colNames:['操作','协商号','协商发起方','协商接收方','出卖单位','买受单位','发货单位','收货单位','价格','数量','最新提交时间','协商状态'],
   	colModel:[ 
   	    {name:'Verify',index:'id',width:60,align:"center",sortable:false},
   	    {name:'xsbh',index:'xsbh', width:100},
   	    {name:'fromusermc',index:'fromusermc', width:100},
   	    {name:'tousermc',index:'tousermc', width:100},
   		{name:'chumdwmc',index:'chumdwmc', width:80},
   		{name:'maisdwmc',index:'maisdwmc', width:80 },	
   		{name:'fahdwmc',index:'fahdwmc', width:80 },
   	    {name:'shouhdwmc',index:'shouhdwmc', width:80 },
   		{name:'jiag',index:'jiag', width:60 },
   		{name:'shul',index:'shul', width:60 },
   		{name:'zxtjsj',index:'zxtjsj', width:80 },	
   		{name:'xszt_show',index:'xszt_show', width:120 }
   	],  
    jsonReader: {
           repeatitems : false, 
           id: 'xsbh'
         },    	
   	rowNum:10,
   	rowList:[10,20,30],     	
   	pager: '#pager'+i,   	
   	rownumbers: true,   	 
    viewrecords: true,
    sortorder: 'desc',  
    altRows:true,  
	caption: "协商交易",
	gridComplete:function()
	{ //在此事件中循环为每一行添加查看链接 
		var ids=jQuery("#myTab"+i).jqGrid('getDataIDs'); 
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j];
			if(i==0)//发起
			{
			  verify ="<a href='#' style='color:#f60' onclick='display("+ id +","+i+")'>编辑</a>";			
			}
			else//接受、达成(不能编辑)
			{
			   verify ="<a href='#' style='color:#f60' onclick='display("+ id +","+i+")'>查看</a>";
			}
			jQuery("#myTab"+i).jqGrid('setRowData',ids[j], { Verify: verify }); 
		} 
	} 	
  });
  $("#myTab"+i).jqGrid('setGridHeight','300px');
  }
  
  
  
//查看  
function display(id,index) { 
  
    if(index==2)//达成
    {
    openwindowview('<%=path %>/htgl/htcxInfo.action?htbh='+id.id+'&index='+index);
    }
    else  //发起、接受
    {
    openwindow('<%=path %>/consult/displayContract.action?xsbh='+id.id+'&index='+index);
    }
    
}

// 查询
function search(){ 
  var formdata = $("#form1").serialize();  
  $("#myTab"+qieye).jqGrid('setGridParam',{url:'<%=path%>/info/xsJqgrid.action?'+formdata,mtype:'post',page:1}).trigger("reloadGrid"); 
}

//查看合同的方法
function openwindowview(url){
    var sheight = screen.height-30;
    var swidth = screen.width-1;
    var winoption ="height="+sheight+"px,width="+ swidth +"px,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=yes,status=yes";
    var result=window.open(url,"newwindow",winoption);
    if(result ==1) window.location.reload(); 
    return result;  
}

//查看未完成协商交易的方法
function openwindow(url){
    var sheight = screen.height-70;
    var swidth = screen.width-10;
    var winoption ="dialogHeight:"+sheight+"px;dialogWidth:"+ swidth +"px;status:yes;scroll:yes;resizable:yes;center:yes";
    var result=window.showModalDialog(url,window,winoption);
    if(result ==1){
     reloadbdxx();
      }
    return result;  
}

function reloadbdxx(){
   window.location.href="<%=request.getContextPath()%>/consult/initQuery.action";
}

//删除
function removeRow() {
    var s = $("#myTab0").jqGrid('getGridParam','selarrrow');
	if (s == "") {
        alert("请先选择报单，再点击删除！");
        return;
    }
	var url = "<%=path%>/gpjy/removeBdxxInfo.action?bdbh="+s;
	$( "#dialog-confirm" ).dialog({
			resizable: false,
			height:140,
			modal: true,
			buttons: {
				"确认": function() {
					$.post(url, function(data) {
                    var json =eval('(' + data + ')');
					if(json.result==1){
					   alert("删除成功！");
					   reloadbdxx();
					}else{
					   alert("删除失败！");
					}                                    
                   }); 
                   $( this ).dialog( "close" );                   
				},
				"返回": function() {
					$( this ).dialog( "close" );
				}
			}
		});
}


//重置
function resetSearch(){
	$('#list_search  input[type=text]').val('');
	$('#list_search select').val('-1');
}

</script>  


<script type="text/javascript">
	//加载执行
    window.onload = function() {    
    var combox = document.getElementById("common_box");
    var cli_on = document.getElementById("cli_on");
    var flag = true, timer = null, initime = null, r_len = 0;
    cli_on.onclick = function () {
    /*如果不需要动态效果，这两句足矣
    combox.style.right = flag?'-270px':0;
    flag = !flag;
    */
    clearTimeout(initime);
    //根据状态flag执开展开收缩
    if (flag) {
    r_len = 0;
    timer = setInterval(slideright, 10);
    } else {
    r_len = -370;
    timer = setInterval(slideleft, 10);
    }
    }
    //展开
    function slideright() {
    if (r_len <= -370) {
    clearInterval(timer);
    flag = !flag;
    return false;
    } else {
    r_len -= 5;
    combox.style.right = r_len + 'px';
    }
    }
    //收缩
    function slideleft() {
    if (r_len >= 0) {
    clearInterval(timer);
    flag = !flag;
    return false;
    } else {
    r_len += 5;
    combox.style.right = r_len + 'px';
    }
    }
    //加载后3秒页面自动收缩
    initime = setTimeout("cli_on.click()", 1000);
    }
    </script>
<body> 

<div id="common_box">
<div id="cli_on">发起协商</div>
<div >
<table  border="0" cellpadding="0" cellspacing="0">
  <tr><td height="32" align="center" class="word_orange">协商交易</td></tr> 
<s:iterator value="myfriends"> 
<tr> 
<td height="23" align="center">
<a href="javascript:openwindow('<%=request.getContextPath() %>/consult/draftContract.action?touserid=${id}')"><c:property name="name"/></a></td>
 </td>
 </tr>
 </s:iterator>   
<tr><td height="30" align="center"><font color="#FF6600">如果没有好友，请在交易定制中查询</font><a href="<%=request.getContextPath() %>/manager/jydz/dzconsult/dzconsult.jsp?tab=Y">点此添加</a></td></tr>
</table>
 </div>
 </div>
    
     
<div id="best1">
<p></p>
<form id="form1" method="post">

<table id="list_search" cellpadding="0" cellspacing="0" border="0"> 
        <tr>
        	<td>协商编号:</td>
            <td><input type="text" class="longtextbox" name="bean.AA"  /></td>
            <td>出卖单位名称:</td>
            <td><input type="text" class="longtextbox" name="bean.BB"  /></td>            
            <td>买受单位名称 :</td>
            <td><input type="text" class="longtextbox" name="bean.CC"  /></td>
        </tr>         
        <tr>
        <td>价格:</td>
        <td>
          <input type="text" class="textboxs" name="bean.DD" onKeyUp="this.value=this.value.replace(/\D/g,'');" />
          --
          <input type="text" class="textboxs" name="bean.EE" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
        <td>数量:</td>
        <td><input type="text" class="textboxs" name="bean.FF" onKeyUp="this.value=this.value.replace(/\D/g,'');" />
          --
          <input type="text" class="textboxs" name="bean.GG" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
        <td>最新提交时间:</td>
            <td>
            	<input id="datepicker" type="text" class="textboxs" name="bean.HH" /> 
            	-- 
            	<input id="datepicker1" type="text" class="textboxs" name="bean.II" />
            </td>
        </tr>
        
		<tr>			
            <td colspan="5" style="float:right">
            <input id="chax" type="button" value="查询" onclick="search();"/>
            <input id="reset" type="button" value="重置" onclick="resetSearch();"/>
            </td>
            <td>&nbsp;</td>
        </tr>
  </table> 
  </form>   
    <div id="tabs">
			<ul>
				<li><a href="#tabs-0">发起协商</a></li>
				<li><a href="#tabs-1">接受协商</a></li>
				<li><a href="#tabs-2">达成协商</a></li>
			</ul>
			<div id="tabs-0">
				<table id="myTab0" class="scroll" cellpadding="0" cellspacing="0"></table>
				<div id="pager0" class="scroll"></div>
				<div id="message0" class="scroll"></div>
			</div>
			<div id="tabs-1">
				<table id="myTab1" class="scroll" cellpadding="0" cellspacing="0"></table>
				<div id="pager1" class="scroll"></div>
				<div id="message1" class="scroll"></div>
			</div>
			<div id="tabs-2">
				<table id="myTab2" class="scroll" cellpadding="0" cellspacing="0"></table>
				<div id="pager2" class="scroll"></div>
				<div id="message2" class="scroll"></div>
			</div>
   </div>
   <div id="dialog-confirm" title="是否确认删除？"></div>
   <div id="dialog-confirm1" title="是否确认提报？"></div>
   <div id="dialog-confirm2" title="是否确认复制？"></div>
</div> 
</body>
</html>
